import json
import logging

import jwt
import requests

from airflow.configuration import conf

try:
    import pwd
except ImportError:
    pass

log = logging.getLogger(__name__)

def verify_username_password(username, password):
    ops_login = conf.get('webserver', 'ops_login')
    data = {
        "username": username,
        "password": password
    }
    result = requests.post(ops_login, data=data, timeout=10)
    if result.status_code == 200:
        return True
    else:
        return False

def verify_username(username):
    ops_verify_username = conf.get('webserver', 'ops_verify_username')
    # ops_verify_username = "http://api.pop.patsnap.info/v2023-03/user/info?querry=%s"
    ops_verify_url = ops_verify_username % (username)
    result = requests.get(ops_verify_url, timeout=10)
    if result.status_code == 200:
        return True
    else:
        return False